<!--
 * @Author: Sunye
 * @Date: 2025-07-14 01:12:48
 * @LastEditors: Sunye
 * @LastEditTime: 2025-07-14 01:48:01
 * @Description: 
-->
<template>
  <el-form :model="form" label-width="auto" style="max-width: 600px">
    <el-form-item label="用户名">
      <el-input v-model="form.name" />
    </el-form-item>

    <el-form-item>
      <el-button type="primary" @click="onSubmit">Create</el-button>
      <el-button>Cancel</el-button>
    </el-form-item>
  </el-form>
</template>

<script lang="ts" setup>
import { reactive, ref } from 'vue'
import axios from 'axios'

// do not use same name with ref
const form = reactive({
  name: '',
})
const url = ref('http://localhost:3000/api/user/userAdd')
interface FormAdd {
  name: string
}
const onSubmit = () => {
  let parmas: FormAdd = {
    name: form.name,
  }
  axios.post(url.value, parmas).then((data: any) => {
    console.log(data)
  })
}
</script>
